package com.jlcloud.core.tenant.aspect;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import com.jlcloud.core.tenant.JlCloudTenantHolder;
import com.jlcloud.core.tenant.annotation.TenantIgnore;

/**
 * 自定义租户切面
 *
 * @author By: JlCloud <br>
 * @Package: com.jlcloud <br>
 * @CreateTime: 2024-12-03 21:45 <br>
 * @Copyright: 2021 www.jilianjituan.com Inc. All rights reserved. <br>
 * @Caution 注意：本内容仅限于冀联人力集团内部传阅，禁止外泄以及用于其他的商业目的 <br>
 */
@Slf4j
@Aspect
public class JlCloudTenantAspect {

	@Around("@annotation(tenantIgnore)")
	public Object around(ProceedingJoinPoint point, TenantIgnore tenantIgnore) throws Throwable {
		try {
			//开启忽略
			JlCloudTenantHolder.setIgnore(Boolean.TRUE);
			//执行方法
			return point.proceed();
		} finally {
			//关闭忽略
			JlCloudTenantHolder.clear();
		}
	}

}
